<?php

define(C("ACCESSACTION"), true);
import('jinghuan.AdminAction');

/**
 * Class ApiAction
 */
class VisitorAction extends AdminAction
{
    function datatable()
    {
        $post = I('post.');
        $this->_default_datatable(Q('visitor'));
//        $post["where"]['status'] = 1;
//        $count = Q('visitor')->where($post["where"])->count();
//        $row = Q('visitor')
//            ->page($post["page"], $post["length"])
//            ->where($post["where"])
//            ->order('id desc')
//            ->select();
//
//        $this->callback(array(
//            'rows' => $row,
//            'echo' => $post["echo"],
//            'count' => $count
//        ));
    }

    /**
     *  添加访客记录
     */
    function do_add()
    {
        $post = I('post.');

        $result = D(JH_VISITOR)->add(array(
            "name" => $post['name'],
            "phone" => $post['phone'],
            "work_unit" => $post['work_unit'],
            "floor" => $post['floor'],
            "time" => time(),
        ));
        $this->callback($result != false);
    }

}